/*
 * @Author: guojiangang guojiangang@hikvision.com.cn
 * @Date: 2024-02-27 13:46:27
 * @LastEditors: guojiangang guojiangang@hikvision.com.cn
 * @LastEditTime: 2024-02-27 14:39:16
 * @FilePath: \cfase:\leetcode\234.回文链表.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @lc app=leetcode.cn id=234 lang=javascript
 *
 * [234] 回文链表
 */

// @lc code=start
/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {boolean}
 */
var isPalindrome = function(head) {
  const arr = []
  while (head !== null) {
    arr.push(head.val)
    head = head.next
  }
  const len = arr.length
  for (let i = 0, j = len - 1; i < j; i++, j--) {
    if (arr[i] !== arr[j]) {
      return false
    }
  }
  return true
};
// @lc code=end

